<?
function getEachSlot ($currentID) {
    for ($a = 0; $a <= 13; $a++) {
        $q = new WP_Query(
            array(
                'post_type' => 'slot',
                'posts_per_page' => 999,
                'meta_key' => 'start_time',
                'orderby' => 'meta_value_num',
                'order' => ASC
            )
        );

        while ($q->have_posts()) : $q->the_post();
            $qid = $q->post->ID;
            if (getPitchID($qid) == $currentID) {
                if (in_array(date('l', strtotime('+' . $a . ' day')), get_field('day', $qid)) && get_field('active', $qid)) {


                    echo "{'date':'";
                    echo date('Ymd', strtotime('+' . $a . ' day'));
                    echo "','day':'";
                    echo date('l, j F Y', strtotime('+' . $a . ' day'));
                    echo "','specialDate':'";
                    echo date('d-m-Y', strtotime('+' . $a . ' day'));
                    echo "','startTime':'";
                    echo get_field('start_time', $qid);
                    echo "','endTime':'";
                    echo get_field('end_time', $qid);
                    echo "','price':'";
                    echo get_field('price', $qid);
                    echo "','slot':'";
                    echo $qid;
                    echo "','pitch':'";
                    echo $currentID;
                    echo "','available':";

                    $data = array(
                        "date" => date('Ymd', strtotime('+' . $a . ' day')),
                        "slot" => $qid
                    );

                    $response = doesBookingConflict($data);
                    if (!$response['conflict']) {
                        echo "true},\n";
                    } else {
                        echo "false},\n";
                    }
                }
            }
        endwhile;
        wp_reset_postdata();
    }
}


